package com.spring.utils.api_v4.controller.ui;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.spring.utils.api_v4.pojo.UserInfo;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@Data
public class DeptItem {
    private int id;
    @NotEmpty(message = "部门名称不能为空")
    private String name;    // 部门名称
    private String des;     // 说明
    @JsonIgnore
    private List<UserInfo> staff;

    public long getStaffCount() {
        if(staff != null){
            return staff.stream().filter(user -> user.getRawRole().equals("普通职工")).count();
        }
        return 0;
    }

    public long getCadreCount() {
        if(staff != null){
            return staff.stream().filter(user -> user.getRawRole().equals("干部")).count();
        }
        return 0;
    }
}
